<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>三角形判定</title>
        <style type="text/css">
            div{
                text-align: center;
            }
        </style>
    </head>
    <body>
        <h3 style="text-align: center">三角形类型判断</h3>
        <div>
            a=<input id="a" name="a" type="number" onkeyup="value = value.replace(/D/g,'')">cm
            b=<input id="b" name="b" type="number" onkeyup="value = value.replace(/D/g,'')">cm
            c=<input id="c" name="c" type="number" onkeyup="value = value.replace(/D/g,'')">cm
        </div>
        <div>
            <button onclick="fun()">判断</button>
        </div>
        <div><textarea id="out" cols="50" rows="10" readonly></textarea></div>
        <script>
            function cmp(a,b){
                return a-b;
            }
            function fun(){
                let arr = [0,0,0];
                arr[0] = Number(document.getElementById("a").value);
                arr[1] = Number(document.getElementById("b").value);
                arr[2] = Number(document.getElementById("c").value);
                arr.sort(cmp);
                //console.log(arr);
                if(arr[0]+arr[1]<arr[2]){
                    document.getElementById("out").innerHTML="三边不能构成三角形";
                    return ;
                }
                if(arr[0]*arr[0]+arr[1]*arr[1]<arr[2]*arr[2]) document.getElementById("out").innerHTML =
                        "输入的三边可以构成锐角三角形";
                else if(arr[0]*arr[0]+arr[1]*arr[1]===arr[2]*arr[2]) document.getElementById("out").innerHTML =
                        "输入的三边可以构成直角三角形";
                else document.getElementById("out").innerHTML =
                        "输入的三边可以构成钝角三角形";
            }
        </script>
    </body>
</html>